package spring.cloud.eureka.customer.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.ribbon.proxy.annotation.Hystrix;

@Service
public class HttpService {
	
    @Autowired
    RestTemplate restTemplate;
    
    @HystrixCommand(fallbackMethod="toError")
    public String hiService(String name) {
        return restTemplate.getForObject("http://EUREKA-CLIENT/hi?name="+name,String.class);
    }
    
    String toError(String name){
    	return "request error";
    }
    
	
}
 